package com.jpro.module.system.api.notice;

import com.jpro.framework.common.pojo.CommonResult;
import com.jpro.framework.common.pojo.PageResult;
import com.jpro.framework.common.util.object.BeanUtils;
import com.jpro.module.system.api.dept.DeptApi;
import com.jpro.module.system.api.dept.dto.DeptRespDTO;
import com.jpro.module.system.api.notice.dto.NoticePageReqDTO;
import com.jpro.module.system.api.notice.dto.NoticeRespDTO;
import com.jpro.module.system.controller.admin.notice.vo.NoticePageReqVO;
import com.jpro.module.system.dal.dataobject.dept.DeptDO;
import com.jpro.module.system.service.dept.DeptService;
import com.jpro.module.system.service.notice.NoticeService;
import org.springframework.context.annotation.Bean;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Collection;
import java.util.List;

import static com.jpro.framework.common.pojo.CommonResult.success;

@RestController // 提供 RESTful API 接口，给 Feign 调用
@Validated
public class NoticeApiImpl implements NoticeApi {

    @Resource
    private NoticeService noticeService;


    @Override
    public CommonResult<NoticeRespDTO> getNotice(Long id) {
        return success(BeanUtils.toBean(noticeService.getNotice(id),NoticeRespDTO.class));
    }

    @Override
    public CommonResult<PageResult<NoticeRespDTO>> getNoticePage(NoticePageReqDTO pageReqVO) {
        return success(BeanUtils.toBean(noticeService.getNoticePage(BeanUtils.toBean(pageReqVO, NoticePageReqVO.class)),NoticeRespDTO.class));
    }

    @Override
    public CommonResult<List<NoticeRespDTO>> getNoticeList(NoticePageReqDTO pageReqVO) {
        return success(BeanUtils.toBean(noticeService.getNoticeList(BeanUtils.toBean(pageReqVO, NoticePageReqVO.class)),NoticeRespDTO.class));
    }
}
